<div ng-controller="storeStatisticsCtrl">
    <ol class="breadcrumb">
        <li><a href="javascript:void(0)">报表管理</a></li>
        <li>店面月统计</li>
    </ol>
    <div class="content-container">
        <div class="query">
            <div class="row">
                <form>
                    <div class="col-lg-2" select-search my-list="stores" select-value="conditions.select_store" key="name" placeholder="请选择店面名称"    >
                    </div>
                    <div class="col-lg-1">
                        <div class="input-group input-group-sm">
                            <input type="text" class="form-control" uib-datepicker-popup="yyyy-MM-dd" ng-model="conditions.start_date" is-open="date_s" close-text="关闭" clear-text="清除" current-text="今天" placeholder="开始时间" ng-focus="date_s=true" />
                        </div>
                    </div>
                    <div class="col-lg-1 u-date">
                        -
                    </div>
                    <div class="col-lg-1">
                        <div class="input-group input-group-sm">
                            <input type="text" class="form-control" uib-datepicker-popup="yyyy-MM-dd" ng-model="conditions.end_date" is-open="date_e" close-text="关闭" clear-text="清除" current-text="今天" placeholder="结束时间" ng-focus="date_e=true" />
                        </div>
                    </div>
                    <div class="col-lg-1">
                        <div class="input-group input-group-sm">
                            <select class="form-control" ng-model="conditions.type" ng-change="query()">
                                <option value="0">放款</option>
                                <option value="1">进件</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-lg-1">
                        <div class="input-group input-group-sm text-right">
                            <button class="btn btn-primary query-btn" ng-click="query()">查询</button>
                        </div>
                    </div>
                    <div class="col-lg-1">
                        <div class="input-group input-group-sm text-right">
                            <button class="btn btn-default query-btn" ng-click="clearQuery()">清除</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div chart-pie data="chartData" style="width: 80%;height:300px;margin: 0 auto;" ng-show="data.length > 0"></div>
        <div class="datagrid">
            <table class="table table-bordered" ng-show="data.length > 0">
                <tr>
                    <th style="width:5%;">序号</th>
                    <th style="width:15%;">店面名称</th>
                    <th style="width:15%;">品牌名称</th>
                    <th style="width:12%;">笔数</th>
                    <th style="width:12%;">占比</th>
                    <th style="width:30%;">金额</th>
                    <th style="width:11%;">操作</th>
                </tr>
                <tr ng-repeat="key in data" ng-click="selectRow(key)" ng-class="{'bg-info' : key.selected}">
                    <td>{{$index+1+(conditions.page-1)*conditions.rows}}</td>
                    <td>{{key.companyName}}</td>
                    <td>{{key.brandName}}</td>
                    <td>{{key.count}}</td>
                    <td>{{key.ratio |addPercentage}}</td>
                    <td>{{key.money}}</td>
                    <td><button class="btn btn-primary btn-sm" ng-click="detail(key.companyId)"><span class="glyphicon glyphicon-glass top-2 right-2"></span>详情</button></td>
                </tr>
            </table>
            <div ng-show="data.length == 0" class="alert alert-warning">
                <span class="glyphicon glyphicon-info-sign"></span>&nbsp;查无相关数据，请重新查询！
            </div>
        </div>
    </div>
    <div alert title="alert.title" content="alert.content" open="alert.open"></div>
</div>
<!-- end controller -->
<script type="text/ng-template" id="detail.html">
<div class="modal-header">
     <button type="button" class="close" ng-click="cancel()"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
    <h3 class="modal-title" id="modal-title">店面月统计详细信息</h3>
</div>
<div class="modal-body" id="modal-body">
    <table class="table table-bordered text-center">
        <thead>
            <tr class="success">
                <td width="45%">车辆型号</td>
                <td width="15%">笔数</td>
                <td width="20%">占比</td>
                <td width="20%">金额</td>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="store in store_detail">
                    <td ng-bind="store.carName"></td>
                    <td ng-bind="store.count"></td>
                    <td ng-bind="store.ratio"></td>
                    <td ng-bind="store.money"></td>
            </tr>
        </tbody>
    </table>
</div>
<div class="modal-footer">
    <button class="btn btn-default" type="button" ng-click="cancel()">取消</button>
</div>
</script>